package cn.stylefeng.guns.sys.core.util;

/**
 * 数据格式化类
 *
 * @author jiangge
 * @date 2020/12/2 15:02
 */
public class DataUtil {

    /**
     * 银行卡号格式化
     *
     * @return
     */
    public static String bankCardNumberFormat(String number) {
        StringBuilder str = new StringBuilder(number.replace(" ", ""));
        int i = str.length() / 4;
        int j = str.length() % 4;
        for (int x = (j == 0 ? i - 1 : i); x > 0; x--) {
            str = str.insert(x * 4, " ");
        }
        return str.toString();
    }

}
